﻿using School;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestSchool
{
    [TestClass()]
    public class CourseTest
    {
        [TestMethod()]
        public void AddStudentTestCorrect()
        {
            Course target = new Course();
            for (int i = 0; i < 30; i++)
            {
                Student student = new Student("Student" + i, 10000 + i);
                target.AddStudent(student);
            }
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void AddStudentTestDuplicate()
        {
            Course target = new Course();
            Student student = new Student("Ivo", 44268);
            target.AddStudent(student);
            target.AddStudent(student);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void AddStudentTestOverMaxCount()
        {
            Course target = new Course();
            for (int i = 0; i < 31; i++)
            {
                Student student = new Student("Student" + i, 10000 + i);
                target.AddStudent(student);
            }
        }

        [TestMethod()]
        public void RemoveStudentTestCorrect()
        {
            Course target = new Course();
            for (int i = 0; i < 30; i++)
            {
                Student student = new Student("Student" + i, 10000 + i);
                target.AddStudent(student);
            }

            for (int i = 0; i < 30; i++)
            {
                Student student = new Student("Student" + i, 10000 + i);
                target.RemoveStudent(student);
            }
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void RemoveStudentTestNonexistent()
        {
            Course target = new Course();
            Student student1 = new Student("Ivo", 44268);
            Student student2 = new Student("Ivo", 44269);
            target.AddStudent(student1);
            target.RemoveStudent(student2);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void RemoveStudentTestAlreadyLeft()
        {
            Course target = new Course();
            Student student1 = new Student("Ivo", 44268);
            Student student2 = new Student("Ivo", 44269);
            target.AddStudent(student1);
            target.AddStudent(student2);
            target.RemoveStudent(student2);
            target.RemoveStudent(student2);
        }
    }
}
